package com.momoauth.common.security;

import com.momoauth.common.security.aspect.RequiresGroupAspect;
import com.momoauth.common.security.aspect.RequiresPermissionsAspect;
import com.momoauth.common.security.aspect.RequiresRolesAspect;
import com.momoauth.common.security.aspect.ValidateRepeatSubmitAspect;
import com.momoauth.common.security.config.AuthConfig;
import com.momoauth.common.security.interceptor.AuthInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * 自动装配
 */
@ConditionalOnWebApplication
@Configuration(proxyBeanMethods = false)
@ComponentScan({"com.momoauth.common.security.dao"})
public class SecurityAutoConfig {

    @Bean
    public AuthInterceptor authInterceptor() {
        return new AuthInterceptor();
    }

    @Bean
    public AuthConfig authConfig() {
        return new AuthConfig();
    }

    @Bean
    public RequiresRolesAspect requiresRolesAspect() {
        return new RequiresRolesAspect();
    }

    @Bean
    public RequiresGroupAspect requiresGroupAspect() {
        return new RequiresGroupAspect();
    }

    @Bean
    public RequiresPermissionsAspect requiresPermissionsAspect() {
        return new RequiresPermissionsAspect();
    }

    @Bean
    public ValidateRepeatSubmitAspect validateRepeatSubmitAspect() {
        return new ValidateRepeatSubmitAspect();
    }
}
